package com.sduept.nwld.dataserver.manager.etl;

import com.sduept.bigdata.fault.manager.StandardLibraryManager;
import com.sduept.bigdata.fault.parser.entity.EquipmentOverhaulDetail;
import com.sduept.bigdata.fault.parser.entity.EquipmentOverhaulETLLibrary;
import com.sduept.bigdata.fault.parser.entity.StandardLibrary;
import com.sduept.bigdata.fault.special.maintenance.manager.MaintenancePersistManager;
import com.sduept.cim.ledger.manager.SubstationLedgerManager;
import com.sduept.cim.ledger.model.SubstationLedger;
import com.sduept.cim.model.core.Substation;
import com.sduept.cim.model.protection.ProtectionEquipment;
import com.sduept.cim.model.wires.ACLineSegment;
import com.sduept.cim.model.wires.Breaker;
import com.sduept.cim.model.wires.BusbarSection;
import com.sduept.cim.model.wires.PowerTransformer;
import com.sduept.core.dao.SuperDAO;
import com.sduept.nwld.dataserver.enums.OverhaulRegexTypeEnum;
import com.sduept.nwld.dataserver.manager.cim.CimManager;
import com.sduept.bigdata.fault.common.ETLDAO;
import com.sduept.nwld.dataserver.manager.protection.ProtectOverhaulManager;
import com.sduept.nwld.dataserver.model.daily.OverhaulMsg;
import com.sduept.nwld.dataserver.util.CimUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Service
@Slf4j
public class EquipmentOverhaulDetailETLManager {
	@Autowired
	private SuperDAO dao;
	
	@Autowired
	private ETLDAO eDao;
	
	@Autowired
	private CimManager cm;
	@Autowired
	private SubstationLedgerManager stationLedgerM;
	@Autowired
	private ProtectOverhaulManager overHaulManager;
	@Autowired
	private StandardLibraryManager standardLibraryManager;
	@Autowired
	private MaintenancePersistManager maintenanceManager;
	
	

	private static String[] mathMain1Keys= new String[]{"主一","主1","主I","保护1","保护I"};
	private static String[] mathMain2Keys= new String[]{"主二","主1","主I","保护1","保护I"};
	private static String[] mathMain3Keys= new String[]{"主三","主1","主I","保护1","保护I"};
	private static String[] mathOther1Keys= new String[]{"辅A","辅a"};
	private static String[] mathOther2Keys= new String[]{"辅B","辅b"};
	private static String[] KEYS_STATIONS=new String[]{"发电厂","水电厂"};
	private static final String PARAM_POWER="电厂";
	
	public  void receiveAndSaveAllData() {
		List<?> list = getAllSourceData();
		receiveAndSave(list);
	}
	public  void receiveAndSavePartData(String date) {
		List<?> list = getAllSourceData(date);
		receiveAndSave(list);
	}
	public  void receiveAndSaveAllDataByDate(String date) {
		List<?> list = getAllSourceDataByDate(date);
		receiveAndSave(list);
	}
	
	public List<?> getAllSourceData(){
		List <?>result = eDao.query("select id,applicationNumber,batchNumber,applicationUnit,workingPlace,primaryEquipmentStatus,secondaryEquipmentStatus,otherRequirements,overhaulContent,batchPowerStartTime,batchPowerEndtTime,applicationPowerStartTime,applicationPowerEndTime,overhaulType,executableUnit from t_equipment_overhaul_detail ");
		return result;
	}
	public List<?> getAllSourceData(String date) {
		String sql = "select id,applicationNumber,batchNumber,applicationUnit,workingPlace,primaryEquipmentStatus,secondaryEquipmentStatus,otherRequirements,overhaulContent,batchPowerStartTime,batchPowerEndtTime,applicationPowerStartTime,applicationPowerEndTime,overhaulType,executableUnit from t_equipment_overhaul_detail "
				+ "where update_time=";
		List<?> result = eDao.query(sql + "'" + date + "'");
		return result;
	}
	public List<?> getAllSourceDataByDate(String date) {
		String sql = "select id,applicationNumber,batchNumber,applicationUnit,workingPlace,primaryEquipmentStatus,secondaryEquipmentStatus,otherRequirements,overhaulContent,batchPowerStartTime,batchPowerEndtTime,applicationPowerStartTime,applicationPowerEndTime,overhaulType,executableUnit from t_equipment_overhaul_detail "
				+ "where update_time like"+ " '%" + date + "%'";
		List<?> result = eDao.query(sql);
		return result;
	}
	public  void receiveAndSave(List<?> list) {
		ETLDataSave equipmentSave = new ETLDataSave(list);
		equipmentSave.saveToBean();
	}
	private static String find0(String regex,String str){
		 Pattern p = Pattern.compile(regex);
	     Matcher m = p.matcher(str);
	     while (m.find()) {
	        return m.group(0);
	     } 
	     return "";
	}
	
	public class ETLDataSave{
		private List<?> list;
		private List<Substation> stations=new ArrayList<Substation>();
		private List<ACLineSegment> aclines=new ArrayList<ACLineSegment>();
		private Map<String,String> paramStationMap=new HashMap<String,String>();
 
		public ETLDataSave(List<?> list) {
			super();
			this.list = list;
			initData();
		}
		
		private void initData(){
			stations = cm.listStationsByVoltageLevel(500,null);
			aclines=cm.getAcLineSegmentsBystandVoltagelevel500();
			
			/*List<StationParam> allParams = pm.findAllParams();
			for(StationParam param:allParams){
				if(StringUtils.isNotEmpty(param.getStationId())){
					paramStationMap.put(param.getStationId(), param.getDesorg());
				}
			}*/
			List<SubstationLedger> stationLedgerList = stationLedgerM.findAllSubstationLedger();
			if(stationLedgerList.size()>0) {
				for (SubstationLedger ledger : stationLedgerList) {
					paramStationMap.put(ledger.getCimId(), ledger.getDispatchUnit());
				}
			}
		}
		/**
		 * 提取出保护相关信息，存储到保护检修管理
		 */
		private void saveOverhaulMsg(EquipmentOverhaulDetail detail){
			OverhaulMsg om = new OverhaulMsg();
			om.setId(detail.getId());
			om.setApplicantCompany(detail.getApplicationUnit());
			om.setContent(detail.getOverhaulContent());
			if(StringUtils.isNotEmpty(detail.getWorkingPlaceId())){
				Substation sub = dao.findById(detail.getWorkingPlaceId(), Substation.class);
				if(sub!=null){
					om.setStation_id(detail.getWorkingPlaceId());
					om.setStation_name(sub.getName());
				}
			}
			Date start = detail.getBatchPowerStartTime();
			Date end = detail.getBatchPowerEndtTime();
			om.setStartTime(start);
			om.setEndTime(end);
			overHaulManager.updateOverhaulMsgBySatus(om);
			dao.createOrUpdate(om,OverhaulMsg.class);
		}
		
		public void saveToBean(){
			List<EquipmentOverhaulDetail> datas = new ArrayList<EquipmentOverhaulDetail>();
			List<EquipmentOverhaulDetail> updatedatas = new ArrayList<EquipmentOverhaulDetail>();
			Map<String, List<StandardLibrary>> etlMap = getETLStandardLibrary();
			for(Object obj : list){
				EquipmentOverhaulDetail deatil=new EquipmentOverhaulDetail();
				Object[] objs = (Object[]) obj;
				if(objs[0]!=null)deatil.setId(objs[0].toString());
				if(objs[1]!=null)deatil.setApplicationNumber(objs[1].toString());
				if(objs[2]!=null)deatil.setBatchNumber(objs[2].toString());
				if(objs[3]!=null)deatil.setApplicationUnit(objs[3].toString());
				if(objs[4]!=null)deatil.setWorkingPlace(objs[4].toString());
				if(objs[5]!=null)deatil.setPrimaryEquipmentStatus(objs[5].toString());
				if(objs[6]!=null)deatil.setSecondaryEquipmentStatus(objs[6].toString());
				if(objs[7]!=null)deatil.setOtherRequirements(objs[7].toString());
				if(objs[8]!=null)deatil.setOverhaulContent(objs[8].toString());
				if(objs[9]!=null)deatil.setBatchPowerStartTime((Date)objs[9]);
				if(objs[10]!=null)deatil.setBatchPowerEndtTime((Date)objs[10]);
				if(objs[11]!=null)deatil.setApplicationPowerStartTime((Date)objs[11]);
				if(objs[12]!=null)deatil.setApplicationPowerEndTime((Date)objs[12]);
				if(objs[13]!=null)deatil.setOverhaulType(objs[13].toString());
				if(objs[14]!=null)deatil.setExecutableUnit(objs[14].toString());
				//如果申请单位为空，择从申请编号中提取 
				if(StringUtils.isEmpty(deatil.getApplicationUnit())&&StringUtils.isNotEmpty(deatil.getApplicationNumber())){
					String appName=find0("[\\u4e00-\\u9fa5]{1,}", deatil.getApplicationNumber());
					deatil.setApplicationUnit(appName);
				}
				if(StringUtils.isNotEmpty(deatil.getWorkingPlace())){
					if(deatil.getWorkingPlace().contains("线")){
						ACLineSegment rtn = cm.getACLineSegmentByName(deatil.getWorkingPlace(), aclines);
						if(null!=rtn) {
							deatil.setWorkingPlaceId(rtn.getId());
						}
					}else{
						for(Substation sub:stations){
							if(CimUtils.stationNameMatching(sub.getName(), deatil.getWorkingPlace())){
								deatil.setWorkingPlaceId(sub.getId());
								deatil.setApplicationUnitId(paramStationMap.get(sub.getId()));
								break;
							}
						}
						if(StringUtils.isEmpty(deatil.getWorkingPlaceId())){
							for(Substation sub:stations){
								if(CimUtils.stationNameMatching(sub.getName(), deatil.getWorkingPlace(),true)){
									deatil.setWorkingPlaceId(sub.getId());
									deatil.setApplicationUnitId(paramStationMap.get(sub.getId()));
									break;
								}
							}
						}
						//为防止出现以下情况 ： 阿海水电厂和阿海发电厂 将发电厂/ 水电厂-> 电厂
						if(StringUtils.isEmpty(deatil.getWorkingPlaceId())){
							for(Substation sub:stations){
								String name = sub.getName();
								name=getReplaceName(name);
								if(CimUtils.stationNameMatching(name, deatil.getWorkingPlace(),true)){
									deatil.setWorkingPlaceId(sub.getId());
									deatil.setApplicationUnitId(paramStationMap.get(sub.getId()));
									break;
								}
							}
						}
						if(StringUtils.isEmpty(deatil.getWorkingPlaceId())){
							ACLineSegment rtn = cm.getACLineSegmentByName(deatil.getWorkingPlace(), aclines);
							if(null!=rtn) {
								deatil.setWorkingPlaceId(rtn.getId());
							}
						}
					}
				}
				//根据一次设备状态匹配涉及的一次设备（线路）
				if(StringUtils.isNotEmpty(deatil.getPrimaryEquipmentStatus())) {
					String[] strings = deatil.getPrimaryEquipmentStatus().split(";");
					for(String s:strings) {
						if(s.contains("转")) {
							String eqName=s.substring(0, s.indexOf("转"));
							apply4Acline(eqName, deatil, aclines,etlMap,false);
							apply4Bus(eqName, deatil,etlMap,false);
							apply4Power(eqName, deatil,etlMap,false);
							apply4Breaker(eqName, deatil,etlMap,false);
						}
					}
				}
				
				//根据检修内容匹配涉及的一次设备
				if(StringUtils.isNotEmpty(deatil.getOverhaulContent())) {
					boolean referOverhaulContentStatus = true;
					String content = deatil.getOverhaulContent();
					List<String> strings = new ArrayList<>();
					if(content.contains(";")) {
						strings = Arrays.asList(content.split(";"));
					}else if(content.contains("；")) {
						strings = Arrays.asList(content.split("；"));
					}else if(content.contains("。")) {
						strings = Arrays.asList(content.split("。"));
					}else {
						strings.add(content);
					}
					for(String eqName:strings) {
							apply4Acline(eqName, deatil, aclines,etlMap,referOverhaulContentStatus);
							apply4Bus(eqName, deatil,etlMap,referOverhaulContentStatus);
							apply4Power(eqName, deatil,etlMap,referOverhaulContentStatus);
							apply4Breaker(eqName, deatil,etlMap,referOverhaulContentStatus);
					}
				}
				//根据二次设备状态匹配涉及的二次设备（保护）
				if(StringUtils.isNotEmpty(deatil.getSecondaryEquipmentStatus())) {
					if(StringUtils.isNotEmpty(deatil.getReferPrimaryEquipments())) {
						String[] strings = deatil.getReferPrimaryEquipments().split(";");
						List<ProtectionEquipment> protectionEquipmentsByAclineId = cm.getProtectionEquipmentsByprotectedIds(strings);
						List<String> types = getType(deatil.getSecondaryEquipmentStatus());
						for(ProtectionEquipment equipment:protectionEquipmentsByAclineId) {
							if(StringUtils.isNotEmpty(equipment.getType())&&types.contains(equipment.getType())) {
								if(StringUtils.isEmpty(deatil.getReferSecondaryEquipments())) {
									deatil.setReferSecondaryEquipment(equipment.getId());
								}else {
									if(!deatil.getReferSecondaryEquipments().contains(equipment.getId()))
										deatil.setReferSecondaryEquipment(deatil.getReferSecondaryEquipments()+";"+equipment.getId());
								}
							}
						}
					}
				}
				if(StringUtils.isEmpty(deatil.getWorkingPlaceId())){
					log.error("此条检修票信息抽取不完善，检修票Id为"+deatil.getId());
				}
				EquipmentOverhaulDetail equipmentOverhaulDetail = dao.findById(deatil.getId(), EquipmentOverhaulDetail.class);
				if(equipmentOverhaulDetail==null||StringUtils.isEmpty(equipmentOverhaulDetail.getId())){
					datas.add(deatil);
				}else {
					updatedatas.add(deatil);
				}
				boolean needCheckecondaryStatus = true;
				//检测检修内容是否含有保护，继保
				if(StringUtils.isNotEmpty(deatil.getOverhaulContent())){
					if(deatil.getOverhaulContent().contains("保护")||deatil.getOverhaulContent().contains("继保")){
						saveOverhaulMsg(deatil);
						needCheckecondaryStatus=false; 
					}
				}
				//检测二次设备状态是否含有保护，继保
				if(needCheckecondaryStatus && StringUtils.isNotEmpty(deatil.getSecondaryEquipmentStatus())){
					if(deatil.getSecondaryEquipmentStatus().contains("保护")||deatil.getSecondaryEquipmentStatus().contains("继保")){
						saveOverhaulMsg(deatil);
					}
				}
				try {
					maintenanceManager.updateMaintenance(deatil);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
			try {
				dao.persistentBatch(EquipmentOverhaulDetail.class, datas);
				//TODO 抽取到保护日报检修？
			} catch (SQLException e) {
				e.printStackTrace();
			}
			for(EquipmentOverhaulDetail e:updatedatas) {
				dao.update(e, EquipmentOverhaulDetail.class);
			}
			
		}
	}
	
	/**
	 * 此方法对于变电站名称进行特殊处理
	 */
	private String getReplaceName(String name){
		for(String str:KEYS_STATIONS){
			name=name.replaceAll(str, PARAM_POWER);
		}
		return name;
	}
	
	/**
	 * 获取 故障抽取字典表，形成一个<类型，字典集合>的map
	 * 
	 * @return
	 */
	private Map<String, List<StandardLibrary>> getETLStandardLibrary() {
		HashMap<String, List<StandardLibrary>> result = new HashMap<String, List<StandardLibrary>>();
		List<StandardLibrary> listAllStandardLibraries = standardLibraryManager.listAllStandardLibraries(EquipmentOverhaulETLLibrary.class);
		for (StandardLibrary tmp : listAllStandardLibraries) {
			if (StringUtils.isEmpty(tmp.getRecordType())) {
				continue;
			}
			List<StandardLibrary> list = result.get(tmp.getRecordType());
			if (null == list) {
				List<StandardLibrary> tmpList = new ArrayList<StandardLibrary>();
				tmpList.add(tmp);
				result.put(tmp.getRecordType(), tmpList);
			} else {
				list.add(tmp);
				result.put(tmp.getRecordType(), list);
			}
		}
		return result;
	}
	
	public List<String> getMatchers(List<StandardLibrary>libs, String source) {
		List<String> list = new ArrayList<>();
		for(StandardLibrary lib:libs){
			Pattern pattern = Pattern.compile(lib.getName());
			Matcher matcher = pattern.matcher(source);
			while (matcher.find()) {
				String string = matcher.group();
				if(!list.contains(string)){
					list.add(matcher.group());
				}
			}
		}
		return list;
	}
	/**
	 * 查找线路
	 * @param eqName
	 * @param deatil
	 * @param aclines
	 * @param referOverhaulContent 
	 */
	private void apply4Acline(String eqName, EquipmentOverhaulDetail deatil,List<ACLineSegment> aclines,Map<String, List<StandardLibrary>> map, boolean referOverhaulContentStatus) {
		ACLineSegment rtn = cm.getACLineSegmentByName(eqName.replaceAll("出线", "").replaceAll("线路", ""), aclines);
		if (null != rtn) {
			String id = rtn.getId();
			if(referOverhaulContentStatus) {
				setReferOverhaulContentsById(deatil,id);
			}else {
				if (StringUtils.isEmpty(deatil.getReferPrimaryEquipments())) {
					deatil.setReferPrimaryEquipments(id);
				} else {
					if (!deatil.getReferPrimaryEquipments().contains(id))
						deatil.setReferPrimaryEquipments(deatil.getReferPrimaryEquipments() + ";" + id);
				}
			}
		}
	}
	
	/**
	 * 根据检修内容塞取设备id
	 * @param deatil 
	 * @param id
	 */
	private void setReferOverhaulContentsById(EquipmentOverhaulDetail deatil, String id) {
		// TODO Auto-generated method stub
		if (StringUtils.isEmpty(deatil.getReferOverhaulContents())) {
			deatil.setReferOverhaulContents(id);
		} else {
			if (!deatil.getReferOverhaulContents().contains(id))
				deatil.setReferOverhaulContents(deatil.getReferOverhaulContents() + ";" + id);
		}
	}
	private boolean existGt500Vol(String str) {
		// 如果有电压等级&电压等级<500 ,返回false,其余为true
		String volRegex = "[0-9]{2,3}kV";
		String string = find0(volRegex, str);
		if (StringUtils.isNotEmpty(string)) {
			volRegex = volRegex.replaceAll("[^\\d]", "");
			int vol = Integer.parseInt(volRegex);
			if (vol < 500) {
				return false;
			}
		}
		return true;
	}
	
	private String getFirstMatcher(String str, List<StandardLibrary> list) {
		String result = "";
		for (StandardLibrary tmp : list) {
			String string = find0(tmp.getName(), str);
			if (StringUtils.isNotEmpty(string)) {
				return string;
			}
		}
		return result;
	}
	/**
	 * 查找母线
	 * @param eqName
	 * @param deatil
	 * @param referOverhaulContentStatus 
	 */
	private void apply4Bus(String eqName,EquipmentOverhaulDetail deatil,Map<String, List<StandardLibrary>> map, boolean referOverhaulContentStatus){
		List<StandardLibrary> list = map.get(OverhaulRegexTypeEnum.BUS_REGEX.getCode());
		boolean matcher = FaultRegexUtil.isMatcher(eqName, list);
		if (!matcher||StringUtils.isEmpty(deatil.getWorkingPlaceId())) {
			return;
		}
		List<StandardLibrary> datdList = map.get(OverhaulRegexTypeEnum.BUS_DATA_REGEX.getCode());
		String equipment=getFirstMatcher(eqName,datdList);
		if(StringUtils.isEmpty(equipment)||!existGt500Vol(eqName)){
			return ;
		}
		//没写电压等级的默认为500kV
		List<BusbarSection> tmpList = cm.getBusbarSectionsByStationIdAndStandVoltagelevel(deatil.getWorkingPlaceId(), 499);
		for(BusbarSection bus:tmpList){
			if(CimUtils.busNameSingleMatching(equipment, bus.getName())){
				String id = bus.getId();
				if(referOverhaulContentStatus) {
					setReferOverhaulContentsById(deatil,id);
				}else {
					if (StringUtils.isEmpty(deatil.getReferPrimaryEquipments())) {
						deatil.setReferPrimaryEquipments(id);
					} else {
						if (!deatil.getReferPrimaryEquipments().contains(id))
							deatil.setReferPrimaryEquipments(deatil.getReferPrimaryEquipments() + ";" + id);
					}
				}
			}
		}
	}
	
	/** 
	 * 查找断路器设备
	 * @param referOverhaulContentStatus 
	 */
	private void apply4Breaker(String eqName,EquipmentOverhaulDetail deatil,Map<String, List<StandardLibrary>> map, boolean referOverhaulContentStatus){
		List<StandardLibrary> list = map.get(OverhaulRegexTypeEnum.BREAKER_REGEX.getCode());
		boolean matcher = FaultRegexUtil.isMatcher(eqName, list);
		if (!matcher||StringUtils.isEmpty(deatil.getWorkingPlaceId())) {
			return;
		}
		List<StandardLibrary> volList = map.get(OverhaulRegexTypeEnum.VOL_REGEX.getCode());
		for(StandardLibrary lib:volList){
			eqName=eqName.replaceAll(lib.getName(), "");
		}
		List<StandardLibrary> dataList = map.get(OverhaulRegexTypeEnum.BREAKER_DATA_REGEX.getCode());
		List<String> matchers = getMatchers(dataList,eqName);
		List<Breaker> tmpList = cm.getBreakersByStationIdAndVoltagelevel(deatil.getWorkingPlaceId(), 499);
		for (String str : matchers) {
			for (Breaker breaker : tmpList) {
				if (CimUtils.breakerNameMatching2(str, breaker.getName())) {
					String id = breaker.getId();
					if(referOverhaulContentStatus) {
						setReferOverhaulContentsById(deatil,id);
					}else {
						if (StringUtils.isEmpty(deatil.getReferPrimaryEquipments())) {
							deatil.setReferPrimaryEquipments(id);
						} else {
							if (!deatil.getReferPrimaryEquipments().contains(id))
								deatil.setReferPrimaryEquipments(deatil.getReferPrimaryEquipments() + ";" + id);
						}
					}
					break;
				}
			}
		}
		
	}
	/**
	 * 查找变压器
	 * @param eqName
	 * @param deatil
	 * @param referOverhaulContentStatus 
	 */
	private void apply4Power(String eqName,EquipmentOverhaulDetail deatil,Map<String, List<StandardLibrary>> map, boolean referOverhaulContentStatus){
		List<StandardLibrary> list = map.get(OverhaulRegexTypeEnum.POWER_REGEX.getCode());
		boolean matcher = FaultRegexUtil.isMatcher(eqName, list);
		if (!matcher||StringUtils.isEmpty(deatil.getWorkingPlaceId())) {
			return;
		}
		List<StandardLibrary> datdList = map.get(OverhaulRegexTypeEnum.POWER_DATA_REGEX.getCode());
		String equipment=getFirstMatcher(eqName,datdList);
		if(StringUtils.isEmpty(equipment)||!existGt500Vol(eqName)){
			return ;
		}
		List<PowerTransformer> tmpList = cm.getPowerTransformersByStationId(deatil.getWorkingPlaceId());
		for(PowerTransformer power:tmpList){
			if(CimUtils.powerNameMatching(equipment, power.getName())){
				String id = power.getId();
				if(referOverhaulContentStatus) {
					setReferOverhaulContentsById(deatil,id);
				}else {
					if (StringUtils.isEmpty(deatil.getReferPrimaryEquipments())) {
						deatil.setReferPrimaryEquipments(id);
					} else {
						if (!deatil.getReferPrimaryEquipments().contains(id))
							deatil.setReferPrimaryEquipments(deatil.getReferPrimaryEquipments() + ";" + id);
					}
				}
			}
		}
	}
	
	
	private List<String> getType(String msg){
		List<String> result = new ArrayList<>();
		for(String str:mathMain1Keys){
			if(msg.contains(str)) {
				result.add("主一保护");
				break;
			}
		}
		for(String str:mathMain2Keys){
			if(msg.contains(str)) {
				result.add("主二保护");
				break;
			}
		}
		for(String str:mathMain3Keys){
			if(msg.contains(str)) {
				result.add("主三保护");
				break;
			}
		}
		for(String str:mathOther1Keys){
			if(msg.contains(str)) {
				result.add("辅A保护");
				break;
			}
		}
		for(String str:mathOther2Keys){
			if(msg.contains(str)) {
				result.add("辅B保护");
				break;
			}
		}
		return result;
	}
}
